import React, { PureComponent } from "react";
import { connect } from "react-redux";
import { getUser, actions } from "../../store/modules/login";
import { bindActionCreators } from "redux";
// import './Login.css'
class Login extends PureComponent {
  render() {
    let {
      user: { phone, password },
      login: { changeUser, reqLogin },
      history,
    } = this.props;
    console.log(this.props);
    return (
      <div className='big'>
          <img src="" alt=""/>
        <div className='inp1'>
          手机号：
          <input
            type="text"
            value={phone}
            onChange={(e) => changeUser("phone", e.target.value) }
          />
        </div>
        <div className='inp2'>
          密码:
          <input
            type="text"
            value={password}
            onChange={(e) => changeUser("password", e.target.value) }
          />
        </div>
        <button onClick={() => reqLogin(history)}>登录</button>
      </div>
    );
  }
}
let mapStateToProps = (state) => ({
  user: getUser(state),
});
let mapDispatchToProps = (dispatch) => ({
  login: bindActionCreators(actions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(Login);
